<template>
  <el-carousel :interval="4000" type="card" height="200px">
    <el-carousel-item v-for="item in 3" :key="item">
      <h3 text="2xl" justify="center">{{ item }}</h3>
    </el-carousel-item>
  </el-carousel>

  <h3> Here is Pinia ↓ </h3>
  <el-button color="#626aef" :dark="isDark" plain @click="countNum()"> 点我 </el-button>
  <p>count: {{ userStore.counter }}</p>
  <p>姓名：{{ userStore.name }}</p>
  <p>性别：{{ userStore.gender }}</p>
</template>

<style scoped>
.el-carousel__item h3 {
  background-image: url('../assets/flower.jpg');
  background-size: cover;
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-image: url('../assets/xiaozhen.jpg');
  background-size: cover;
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-image: url('../assets/flower.jpg');
  background-size: cover;
  background-color: #d3dce6;
}
</style>

<script setup>
import { storeToRefs } from 'pinia';
import { useUsersStore } from '../stores/user'
const userStore = useUsersStore()
const { name, age, gender, counter } = storeToRefs(userStore);
const countNum = () => {
  let co = userStore.increment();
  return userStore.doubleCount(co)
}
</script>
